package net.kindleit.mpd.jukebox;

import java.util.List;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.IModel;
import org.bff.javampd.MPD;

/**
 * Homepage
 */
public class HomePage extends WebPage {

	private static final long serialVersionUID = 1L;

	// TODO Add any page properties or variables here

    /**
	 * Constructor that is invoked when page is invoked without a session.
	 *
	 * @param parameters
	 *            Page parameters
	 */
    public HomePage(final PageParameters parameters) {
      final MPD mpd = ((WicketApplication) WicketApplication.get()).getMPD();
      final IModel<List<String>> statusModel = new MPDStatusModel(mpd);
      add(new ListView<String>("mpdStatus", statusModel) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<String> msgLine) {
          msgLine.add(new Label("msgLine", msgLine.getModelObject()));
        }

      });

      add(new MPDControlPanel("controlPanel", mpd));
    }
}
